package com.xinchuang.domain.pojo;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>
 *
 * </p>
 *
 * @author zx
 * @since 2023-07-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class TestNoticeProductionProcessTable implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 标识ID
     */
    @TableId
    private String productionId;

    /**
     * 通知单ID
     */
    private String parentNoticeId;

    /**
     * 材料名称/牌号
     */
    private String materialName;

    /**
     * 烘料温度
     */
    private String bakingTemperature;

    /**
     * 烘料时间
     */
    private String bakingTime;

    /**
     * 储存终点位置
     */
    private String endPosition;

    /**
     * 保压时间
     */
    private String holdingTime;

    /**
     * 保压压力
     */
    private String holdingPressure;

    /**
     * 保压速度
     */
    private String holdingSpeed;

    /**
     * 冷却时间
     */
    private String coolingTime;

    /**
     * 射胶参数-压力
     */
    private String sprueFeedingPressure;

    /**
     * 射胶参数-速度
     */
    private String sprueFeedingSpeed;

    /**
     * 射胶参数-位置
     */
    private String sprueFeedingPosition;

    private String sprue;

    private String screwTemperature;

    /**
     * 模温
     */
    private String moldTemperature;

    /**
     * 热道流温度
     */
    private String heatedTemperature;

    /**
     * 顺序阀进胶方式
     */
    private String sprueFeedingMethod;

    /**
     * 手画板图片
     */
    private String image;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @Override
    public String toString() {
        StringBuffer buffer = new StringBuffer();
        if (StringUtils.isNotBlank(materialName)) {
            buffer.append("材料名称=" + materialName + ";");
        }
        if (StringUtils.isNotBlank(bakingTemperature)) {
            buffer.append("烘料温度=" + bakingTemperature + ";");
        }
        if (StringUtils.isNotBlank(bakingTime)) {
            buffer.append("烘料时间=" + bakingTime + ";");
        }
        if (StringUtils.isNotBlank(endPosition)) {
            buffer.append("储存终点位置=" + endPosition + ";");
        }
        if (StringUtils.isNotBlank(holdingTime)) {
            buffer.append("保压时间=" + holdingTime + ";");
        }
        if (StringUtils.isNotBlank(holdingPressure)) {
            buffer.append("保压压力=" + holdingPressure + ";");
        }
        if (StringUtils.isNotBlank(holdingSpeed)) {
            buffer.append("保压速度=" + holdingSpeed + ";");
        }
        if (StringUtils.isNotBlank(holdingSpeed)) {
            buffer.append("保压速度=" + holdingSpeed + ";");
        }
        if (StringUtils.isNotBlank(coolingTime)) {
            buffer.append("冷却时间=" + coolingTime + ";");
        }
        if (StringUtils.isNotBlank(moldTemperature)) {
            buffer.append("模温=" + moldTemperature + ";");
        }
        if (StringUtils.isNotBlank(heatedTemperature)) {
            buffer.append("热道流温度=" + heatedTemperature + ";");
        }
        JSONArray array = JSONArray.parseArray(sprue);
        for (int i = 0; i < array.size(); i++) {
            JSONObject object = array.getJSONObject(i);
            if (StringUtils.isNotBlank(object.getString("ejectionTempresure"))) {
                buffer.append("射胶参数-第" + (i + 1) + "段-压力:" + object.getString("ejectionTempresure") + ";");
            }
            if (StringUtils.isNotBlank(object.getString("ejectionposition"))) {
                buffer.append("射胶参数-第" + (i + 1) + "段-位置:" + object.getString("ejectionposition") + ";");
            }
            if (StringUtils.isNotBlank(object.getString("ejectionSpeed"))) {
                buffer.append("射胶参数-第" + (i + 1) + "段-速度:" + object.getString("ejectionSpeed") + ";");
            }
        }
        JSONArray array1 = JSONArray.parseArray(screwTemperature);
        for (int i = 0; i < array1.size(); i++) {
            JSONObject object = array1.getJSONObject(i);
            if (StringUtils.isNotBlank(object.getString("temperatureValue"))) {
                buffer.append("螺杆温度-第" + (i + 1) + "段:" + object.getString("temperatureValue") + ";");
            }
        }
        JSONArray array2 = JSONArray.parseArray(sprueFeedingMethod);
        for (int i = 0; i < array2.size(); i++) {
            JSONObject object = array2.getJSONObject(i);
            if (StringUtils.isNotBlank(object.getString("gluingmethod"))) {
                buffer.append("顺序阀进胶方式-" + (i + 1) + ":" + object.getString("gluingmethod") + ";");
            }
        }
        if (buffer.length() > 0) {
            return "产品工艺参数{" + buffer.toString() + "}";
        } else {
            return null;
        }
    }
}
